<template>
  <div class="view-wrapper">
    <el-tabs tab-position="left">
      <el-tab-pane label="表单详情">
        <div
          class="render-form"
          id="printForm"
          ref="renderForm"
          :style="{
            'min-height': dataobj.canTodo
              ? '574px'
              : dataobj.code === 'drug_bill_personal' ||
                dataobj.code === 'drug_bill_cadre'
              ? 'auto'
              : '800px',
            width:
              dataobj.code === 'housing_bill_apply' ||
              dataobj.code === 'office_bill_apply'
                ? '950px'
                : '1160px',
            margin: '0 auto',
          }"
        >
          <div v-if="dataobj.formType != '2'">
            <div
              class="header"
              v-if="headerFlag"
              :style="{
                height: headerObj.height,
                background: headerObj.background,
              }"
            >
              <div
                :style="{
                  color: headerObj.styles.color,
                  fontSize: headerObj.styles.fontSize,
                  marginBottom: headerObj.styles.marginBottom,
                }"
              >
                {{ headerObj.value }}
              </div>
              <el-button
                type="text"
                icon="el-icon-printer"
                class="new-print-btn noprint"
                v-print="printObj"
              ></el-button>
              <el-button
                round
                icon="el-icon-top-left"
                v-if="dataobj.canRevoke"
                style="position: absolute; right: 50px; color: #aaa"
                @click="revoke(dataobj)"
                class="noprint"
                >撤回</el-button
              >
              <!-- <el-button type="primary" style="position:absolute;right: 10px;" icon="el-icon-printer" @click="printer">打印</el-button> -->
            </div>
            <avue-form ref="form" :option="newOption" v-model="form">
              <template slot="menuForm">
                <el-button @click="close">关闭</el-button>
              </template>
            </avue-form>
            <!-- <el-form v-model="form"
                  ref="widgetForm"
                  size="small">
              <widget-form-item v-for="(column, index) in newOption.column"
                :item="column" :params="column.params"></widget-form-item>
                <div class="footers">
                  <el-button type="primary" @click="submitForm('form')">立即创建</el-button>
                  <el-button @click="resetForm('form')">重置</el-button>
                </div>
          </el-form> -->
          </div>
          <div v-else>
            <house-bill
              v-if="dataobj.code === 'housing_bill_apply'"
              @getItemModal="getItemModal"
              @printForm="printer"
              :detailObj="dataobj"
              :form1="form1"
            ></house-bill>
            <office-bill
              v-if="dataobj.code === 'office_bill_apply'"
              @getItemModal="getItemModal"
              @printForm="printer"
              :detailObj="dataobj"
              :form1="form2"
            ></office-bill>
            <total-bill
              v-if="dataobj.code === 'meeting_bill_apply'"
              @getItemModal="getItemModal"
              @printForm="printer"
              :detailObj="dataobj"
              :form1="form1"
              ref="newData"
            ></total-bill>
          </div>
        </div>
        <div
          v-if="dataobj.canTodo"
          style="margin-top: 30px; padding-top: 10px"
          :style="{
            width:
              dataobj.code === 'housing_bill_apply' ||
              dataobj.code === 'office_bill_apply'
                ? '950px'
                : '1160px',
            margin: '0 auto',
          }"
        >
          <div>批复：</div>
          <el-autocomplete
            class="inline-input"
            v-model="state1"
            type="textarea"
            :maxlength="120"
            :fetch-suggestions="querySearch"
            placeholder="请输入内容"
          ></el-autocomplete>
          <div style="text-align: center; margin-top: 20px">
            <el-select
              v-model="form.assignee"
              v-if="showSelect"
              multiple
              class="manager-select"
              style="width: 220px !important; margin-right: 10px"
              :placeholder="placeholder"
              clearable
            >
              <el-option
                v-for="item in optionsUser"
                :key="item.userId"
                :label="item.realname"
                :value="item.username"
              >
              </el-option>
            </el-select>
            <el-button
              :type="
                item !== '不同意'
                  ? item !== '同意'
                    ? 'primary'
                    : 'success'
                  : 'danger'
              "
              v-for="(item, index) in dataobj.flagList"
              :key="index"
              @click="saveNodeTask(item)"
              :style="{ 'margin-left': item == '送审批' ? '70px' : '10px' }"
              >{{ item }}</el-button
            >
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="流转信息">
        <el-timeline>
          <el-timeline-item
            :timestamp="item.time"
            placement="top"
            v-for="item in dataobj.commitList"
            :key="item.id"
          >
            <div v-if="item.taskStatus === '1'">
              <el-card>
                <h4>
                  {{ item.realname }} 在[{{ item.time }}] 开始处理[{{
                    item.taskName
                  }}] 环节
                </h4>
                <p>结束时间：{{ item.endTime }}</p>
              </el-card>
            </div>
            <div v-else>
              <el-card>
                <h4>
                  {{ item.nameStr }} 在[{{ item.time }}] 开始处理[{{
                    item.taskName
                  }}] 环节
                </h4>
              </el-card>
            </div>
          </el-timeline-item>
        </el-timeline>
      </el-tab-pane>
      <el-tab-pane label="流程跟踪">
        <viewer>
            <img style="height: 300px; max-width: 100%" :src="'/act/task/viewByProcessId/' + processInstanceId">
        </viewer>
        <h3>流程跟踪历史</h3>
        <avue-crud
          ref="crud"
          :page.sync="page"
          :data="tableData1"
          :permission="permissionList"
          :option="tableOption"
        >
        </avue-crud>
      </el-tab-pane>
    </el-tabs>
    <choose-member
      v-if="showChose"
      :labelkey="labelkey"
      :url1="url1"
      :url2="url2"
      :title="title"
      :columns1="columns1"
      :columns="columns"
      :limitLabel="limitLabel"
      :flKey="flKey"
      :type="type"
      :chosedKey="chosedKey"
      :choselist="choselist"
    ></choose-member>
    <el-dialog
      title="已选资产"
      class="asset-dialog"
      v-if="dialogVisible1"
      :visible.sync="dialogVisible1"
      @close="closeDialog1"
      :close-on-click-modal="false"
      top="5vh"
      width="900"
    >
      <a-table
        :row-key="'assetId'"
        :columns="columns"
        :scroll="{ y: 'calc(100vh - 364px)' }"
        :data-source="tableData"
        :row-selection="{
          selectedRowKeys: selectedRowKeys1,
          type: 'checkbox',
          onChange: selectMembers1,
          columnTitle: ' ',
        }"
        bordered
        :pagination="page2"
        :loading="loading1"
        @change="handleTableChange1"
      >
        <template slot="deptId" slot-scope="text, record">
          <span>
            {{ record.deptName }}
          </span>
        </template>
        <template slot="post" slot-scope="text, record">
          <span>
            {{ getPostName(record.post) }}
          </span>
        </template>
        <template slot="cover" slot-scope="text, record">
          <img :src="record.cover" alt="" height="34" />
        </template>
      </a-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeDialog1">取 消</el-button>
        <el-button type="primary" @click="alarmHandle">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script type="text/ecmascript-6">
import _ from "lodash";
import eventBus from "@/util/eventBus";
import { getDays } from "@/util/util";
import HouseBill from "@/components/house-bill";
import officeBill from "@/components/office-bill";
import { remote } from "@/api/admin/dict";
import { leaderAll, userSelectAll } from "@/api/admin/user";
import { startProcess, billSubmit, billRevoke } from "@/api/bill";
import { mapGetters } from "vuex";
import { fetchTree } from "@/api/admin/sysarea";
import { getParentsNameById, accAdd } from "@/util/util";
import chooseMember from "@/components/chooseMember";
import totalBill from "@/components/total-bill";
import { setStore } from "@/util/store";
import WidgetFormItem from "@/components/table-design/newFormItem";
export default {
  components: {
    WidgetFormItem,
    HouseBill,
    officeBill,
    chooseMember,
    totalBill,
  },
  props: ["option", "dataobj", "driverList"],
  data() {
    return {
      dialogVisible1: false,
      form: {},
      placeholder: "请选择经办人",
      printObj: {
        id: "printForm", //打印区域 Dom ID
        popTitle: "打印页面标题文字",
        ignoreClass: "noprint",
        extraCss: "https://www.google.com,https://www.google.com",
        extraHead:
          '<meta http-equiv="Content-Language"content="zh-cn"/>,<style> #printForm { height: auto !important; } <style>', //  可以传进去  style tag 标签；注意要逗号分隔   解决特定区域不显示问题；
      },
      showSelect: false,
      optionsUser: [],
      disableUser: false,
      selectedRowKeys1: [],
      form1: {
        housingId: "",
        bedId: "",
        roomNumber: "",
        bedNumber: "",
        address: "",
        usageArea: null,
        rentArea: null,
        defaultRent: null,
        constructionArea: null,
        sharingArea: null,
        roomArea: null,
        housingType: "",
        structure: "",
        leadDate: "",
        remark: "",
      },
      form2: {
        officeId: "",
        address: "",
        roomNumber: "",
        roomType: "",
        roomArea: null,
        useType: "",
        remark: "",
        leadDate: "",
        useDates: "",
      },
      typeList: ["primary", "success", "info", "warning", "danger"],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 100, // 每页显示多少条
      },
      restaurants: [],
      state1: "",
      tableData1: [],
      tableData: [],
      processInstanceId: "",
      headerObj: {},
      tableOption: {
        border: true,
        index: true,
        indexLabel: "序号",
        stripe: true,
        menu: false,
        align: "center",
        dialogClickModal: false,
        refreshBtn: false,
        searchBtn: false,
        column: [
          {
            type: "text",
            label: "节点名称",
            prop: "taskName",
            span: 12,
          },
          {
            type: "text",
            label: "部门",
            prop: "deptName",
            span: 12,
          },
          {
            type: "text",
            label: "处理人",
            prop: "realname",
            span: 12,
          },
          {
            type: "text",
            label: "处理意见",
            prop: "message",
            span: 12,
          },
          {
            type: "text",
            label: "开始时间",
            prop: "time",
            width: 140,
            span: 12,
          },
          {
            type: "text",
            label: "结束时间",
            width: 140,
            prop: "endTime",
            span: 12,
          },
          {
            type: "text",
            label: "天数",
            prop: "days",
            span: 12,
          },
          {
            type: "text",
            label: "状态",
            prop: "taskStatus",
            span: 12,
            dicUrl: "/admin/dict/type/task_handle_status",
          },
        ],
      },
      areaData: [],
      loading1: false,
      page2: {
        total: 0, // 总页数
        current: 1, // 当前页数
        pageSize: 20, // 每页显示多少条,
        isAsc: false, // 是否倒序
      },
      bizData: {},
      permissionList: {
        addBtn: false,
        delBtn: false,
        editBtn: false,
      },
      headerFlag: false,
      newOption: {},
      showChose: false,
      edom: "",
      url1: "",
      url2: "",
      chosedKey: [],
      choselist: [],
      type: "checkbox",
      limitLabel: "",
      columns: [],
      columns1: [],
      title: "",
      flKey: "",
      labelkey: "",
    };
  },
  watch: {
    "form.method": {
      handler(val) {
        var field_driverId_label = this.findObject(
          this.option.column,
          "driverId_label"
        );
        var field_driverId = this.findObject(this.option.column, "driverId");
        var field_carNo_label = this.findObject(
          this.option.column,
          "carNo_label"
        );
        var field_carNo = this.findObject(this.option.column, "carNo");
        if (val === "1") {
          field_driverId_label.display = true;
          field_driverId.display = true;
          field_carNo_label.display = true;
          field_carNo.display = true;
        } else {
          field_driverId_label.display = false;
          field_driverId.display = false;
          field_carNo_label.display = false;
          field_carNo.display = false;
        }
      },
    },
    "form.car_address": {
      handler(val) {
        var field_address_other = this.findObject(
          this.option.column,
          "address_other"
        );
        if (val === "其他") {
          field_address_other.display = true;
        } else {
          field_address_other.display = false;
        }
      },
    },
    "form.carType": {
      handler(val) {
        var field_number = this.findObject(this.option.column, "number");
        var field_number_label = this.findObject(
          this.option.column,
          "number_label"
        );
        if (val === "2") {
          //来访车辆
          field_number.display = true;
          field_number_label.display = true;
        } else {
          field_number.display = false;
          field_number_label.display = false;
        }
      },
    },
    "form.workTimePrice": {
      handler(val) {
        if (this.form.consumablePrice) {
          this.form.workPrice = accAdd(this.form.consumablePrice, val);
        }
      },
    },
    "form.consumablePrice": {
      handler(val) {
        if (this.form.workTimePrice) {
          this.form.workPrice = accAdd(this.form.workTimePrice, val);
        }
      },
    },
  },
  created() {
    let _this = this;
    console.log(this.dataobj, "@333");
    this.init();
    // if (this.dataobj.canTodo && this.dataobj.taskConfig && this.dataobj.taskConfig.properties && this.dataobj.code !== 'car_bill_apply') {
    if (
      this.dataobj.canTodo &&
      this.dataobj.taskConfig &&
      this.dataobj.taskConfig.properties
    ) {
      this.listener();
    }
    this.getPfy();
    this.eventBusHandle();
    this.bizData = {};
    // this.dataobj.showSelectType = 'ROLE_SERVICE_CHARGE_LEADER'
    this.processInstanceId = this.dataobj.processInstanceId;
    this.tableData1 = this.dataobj.commitList;
    this.dataobj.commitList.map((item) => {
      if (item.taskStatus === "0") {
        let assignee = JSON.parse(item.assignee);
        let nameStr = [];
        if (assignee.length > 0) {
          assignee.map((v) => {
            nameStr.push(v.realname);
          });
          item.nameStr = nameStr.join();
        }
      }
      item.days = "<" + getDays(item.duration);
    });
    let content = JSON.parse(this.dataobj.content);
    if (this.dataobj.code === 'visiting_bill_apply') {
      content.startTime = this.dataobj.startTime;
      content.endTime = this.dataobj.endTime;
    }
    this.choselist = content?.choselist;
    if (content?.driverId && this.driverList && this.driverList.length > 0) {
      let drivername = this.driverList.filter((item) => {
        return item.driverId === content.driverId;
      })[0].driverName;
      content.driverId = drivername;
    }
    if (content?.attachment) {
      if (typeof content.attachment == "string") {
        this.dataobj.attachment = JSON.parse(content.attachment);
      } else if (typeof content.attachment == "object") {
        this.dataobj.attachment = content.attachment;
      }
    }
    if (content?.idCard) {
      this.dataobj.idCard = content.idCard;
    }
    if (content?.housing) {
      this.dataobj.housing = content.housing;
    }
    if (content?.parking) {
      this.dataobj.parking = content.parking;
    }
    if (content?.fileList1) {
      this.dataobj.fileList1 = content.fileList1;
    }
    if (content?.fileList2) {
      this.dataobj.fileList2 = content.fileList2;
    }
    if (content?.billChecked) {
      this.dataobj.billChecked = content.billChecked;
    }
    if (content?.withMember) {
      this.form.withMember = content.withMember;
    }
    if (content?.applyTimes && content.applyTimes.length) {
      this.dataobj.applyBeginTime = content.applyTimes[0]
        ? content.applyTimes[0]
        : "";
      this.dataobj.applyEndTime = content.applyTimes[1]
        ? content.applyTimes[1]
        : "";
    }
    if (content?.housing) {
      this.form1 = Object.assign(this.form1, content, content.housing);
    } else {
      this.form1 = Object.assign(this.form1, content);
    }
    // if (this.dataobj.showSelectType &&  this.dataobj.showSelectType == 'ROLE_SERVICE_HANDEL') {
    if (this.dataobj.showSelectType) {
      let atts = this.dataobj.showSelectType.split("_#_");
      if (atts.length > 1) {
        this.placeholder = "请选择" + atts[1];
        // } else {
        //     if(this.dataobj.showSelectType == 'ROLE_SERVICE_HANDEL' || this.dataobj.showSelectType == 'ROLE_SERVICE_ASSET_HANDEL') {
        //     this.placeholder = '请选择经办人'
        //   } else if (this.dataobj.showSelectType == 'ROLE_SERVICE_GROUP_LEADER_KS') {
        //     this.placeholder = '请选择科组长'
        //   } else if (this.dataobj.showSelectType == 'ROLE_SERVICE_CHARGE_LEADER') {
        //     this.placeholder = '请选择分管领导'
        //   }
      }

      // userSelectAll(this.dataobj.showSelectType, this.userInfo.username).then(res => {
      userSelectAll(atts[0], this.userInfo.username).then((res) => {
        this.showSelect = true;
        this.optionsUser = res.data.data;
      });
    }
    if (this.option && this.option.column && this.option.column.length > 0) {
      let column = [];
      this.option.column.map((item) => {
        item.readonly = true;
        item.disabled = true;
        // switch (item.prop) {
        //   case "createName":
        //     item.value = this.dataobj.createName;
        //     break;
        //   case "createPhone":
        //     item.value = this.dataobj.createPhone;
        //     break;
        //   case "deptName":
        //     item.value = this.dataobj.deptName;
        //     break;
        // }
        if (content&&content[item.prop]) {
          item.value = content[item.prop];
        }
        if (
          item.prop === "car_address" ||
          item.prop === "carModel" ||
          item.prop === "reason"
        ) {
          item.disabled = true;
        }
        if (item.type === "header") {
          this.headerFlag = true;
          this.headerObj = item;
        } else {
          if (item.height) {
            // 选药表格
            if (
              (item.height === "auto" &&
                (item.prop === "drugList_choose_member" ||
                  item.prop === "officegoodsList_choose_member" ||
                  item.prop === "assetList_choose_member")) ||
              (item.height === "151px" && item.prop === "attachment")
            ) {
              let styles = {
                height: item.height,
                overflow: "auto",
              };
              if (item.styles) {
                item.styles = Object.assign(item.styles, styles);
              } else {
                item.style = styles;
              }
            } else if (
              item.height === "110px" &&
              item.prop === "purchase_form"
            ) {
              let styles = {
                height: item.height,
                overflow: "auto",
                "margin-left": "-50px",
              };
              if (item.styles) {
                item.styles = Object.assign(item.styles, styles);
              } else {
                item.style = styles;
              }
            } else {
              let styles = {
                height: item.height,
                "align-items": "center",
                display: "inline-flex",
              };
              if (item.styles) {
                item.styles = Object.assign(item.styles, styles);
              } else {
                item.style = styles;
              }
            }
          }
          column.push(item);
        }
        // 编辑页面其他出车地点有值即显示
        if (item.prop === "address_other" && item.value) {
          item.display = true;
        }
        // 资产交换
        if (
          this.dataobj.code === "asset_bill_change" &&
          (item.prop === "categoryId" ||
            item.type === "number" ||
            item.prop === "cover")
        ) {
          item.disabled = true;
        }
        // 资产采购
        if (
          this.dataobj.code === "asset_bill_purchase" &&
          item.type === "number"
        ) {
          item.disabled = true;
        }
        // ic卡、座机申请、长途申请
        if (
          this.dataobj.code === "card_bill_apply" ||
          this.dataobj.code === "telephone_bill_apply" ||
          this.dataobj.code === "telephone_bill_long"
        ) {
          if (item.type === "number" || item.type === "select") {
            item.disabled = true;
          }
        }
        // 停车
        if (
          this.dataobj.code === "parking_bill_apply" &&
          (item.type === "radio" || item.type === "number")
        ) {
          item.disabled = true;
        }
        // 来访
        if (
          this.dataobj.code === "visiting_bill_apply" &&
          item.type === "radio"
        ) {
          item.disabled = true;
        }
        //公务用车申请
        if (this.dataobj.code === "car_bill_apply"&&item.prop === "startTime") {
              _this.form.startTime = this.form1.useTimes[0];
        }
        if (this.dataobj.code === "car_bill_apply"&&item.prop === "endTime") {
              _this.form.endTime = this.form1.useTimes[1];
        }
        //意见建议,资产变动
        if (
          (this.dataobj.code === "suggest_bill_apply" ||
            this.dataobj.code === "asset_bill_handover") &&
          item.prop === "attachment"
        ) {
          item.disabled = true;
        }
        if (
          item.prop === "workTime" ||
          item.prop === "workPrice" ||
          item.prop === "consumablePrice" ||
          item.prop === "workTimePrice" ||
          item.prop === "areaId" ||
          item.prop === "migrateAreaId"
        ) {
          item.disabled = true;
        }
        if (
          item.type === "dynamic" &&
          item.children &&
          item.children.column.length > 0
        ) {
          item.children.column.map((c) => {
            if (c.type === "number") {
              c.disabled = true;
            }
            if (this.dataobj.code === "asset_bill_purchase") {
              c.disabled = true;
            }
            // 办公用品采购申请
            if (this.dataobj.code === "officegoods_bill_purchase") {
              c.disabled = true;
            }
            if (
              this.dataobj.canTodo &&
              this.dataobj.taskConfig &&
              this.dataobj.taskConfig.properties &&
              (c.label === "资产名称【请选择+】" ||
                c.label === "退库资产【请选择+】" ||
                c.label === "借用资产【请选择+】" ||
                c.label === "变动资产【请选择+】" ||
                c.label === "采购资产【请选择+】")
            ) {
              c.label = "已选资产【请选择+】";
              _this.tableData = item.value;
            }
          });
        }
        if (item.prop.indexOf("_choose_member") !== -1) {
          if (
            this.dataobj.code === "asset_bill_revert" ||
            this.dataobj.code === "asset_bill_purchase" ||
            this.dataobj.code === "asset_bill_handover" ||
            this.dataobj.code === "asset_bill_requisition" ||
            this.dataobj.code === "asset_bill_borrow" ||
            this.dataobj.code === "car_bill_apply"
          ) {
            if (
              this.dataobj.code === "asset_bill_handover" ||
              item.prop === "withMember_choose_member"
            ) {
              _this.form[item.prop] = item.value;
            } else {
              let astr = item.prop.replace("_choose_member", "");
              _this.form[item.prop] =content? content[astr]:null;
            }
          } else {
            _this.form[item.prop] = item.value;
          }
        }
        // let att = []
        this.dataobj.commitList.map((citem) => {
          if (citem.taskStatus === "1" && citem.taskName === item.prop) {
            item.value =
              "【" +
              citem.deptName +
              "-" +
              citem.realname +
              "】:" +
              (citem.message ? citem.message : "") +
              "。（" +
              citem.endTime +
              "）";
          }
          // if (citem.taskName === '机关服务中心科组意见') {
          //   att.push('【' + citem.deptName + '-' + citem.realname + '】:' + (citem.message ? citem.message : '') + '。（' + citem.time + '）')
          // }
        });
        // if (att.length > 1) {
        //   if (item.prop === '机关服务中心科组意见1') {
        //     item.value = att[att.length - 1]
        //   }
        //   if (item.prop === '机关服务中心科组意见') {
        //     item.value = att[att.length - 2]
        //   }
        // }
        // 办结节点 ||  资产领用发放节点 || 打回
        if (
          this.dataobj.canTodo &&
          this.dataobj.taskConfig &&
          this.dataobj.taskConfig.properties
        ) {
          let properties = JSON.parse(this.dataobj.taskConfig.properties);
          properties.column &&
            properties.column.map((citem) => {
              if (citem.prop === item.prop && !citem.disable) {
                item.readonly = false;
                item.disabled = false;
                this.bizData[citem.prop] = "";
              }
              // 选药显示发放数量
              if (
                ((citem.prop === "drugList" &&
                  item.prop === "drugList_choose_member") ||
                  (citem.prop === "officegoodsList" &&
                    item.prop === "officegoodsList_choose_member")) &&
                item.children.column &&
                item.children.column.length > 0
              ) {
                item.disabled = false;
                item.readonly = false;
                item.children.column.map((c) => {
                  if (c.prop === "realAmount") {
                    c.width = 180;
                    c.disabled = false;
                  }
                  if (c.prop === "preAmount") {
                    c.disabled = false;
                  }
                });
              }
            });
          // 当来访人员选择上楼拜访，楼下接待不可选择
          if(this.dataobj.code==="visiting_bill_apply"&&this.dataobj.upstairFlag==="1"&&item.prop==="downstairRoomNo"){
            item.readonly = true;
            item.disabled = true;
          }
          // 当来访人员选择不停车时，停车安排不可填写
          if(this.dataobj.code==="visiting_bill_apply"&&this.dataobj.parkFlag==="0"&&item.prop==="parkArrange"){
            item.readonly = true;
            item.disabled = true;
          }
          if (item.prop === "officegoodsList_choose_member") {
            _this.form.officegoodsList_choose_member &&
              _this.form.officegoodsList_choose_member.map((v) => {
                v.realAmount = v.preAmount;
              });
          }
          if (item.prop === "drugList_choose_member") {
            _this.form.drugList_choose_member &&
              _this.form.drugList_choose_member.map((v) => {
                v.realAmount = v.preAmount;
              });
          }
        } else {
          if (item.type === "select") {
            item.disabled = true;
          }
        }
        // if (this.dataobj.showSelectType) {
        //   item.readonly = false
        //   item.disabled = false
        // }
        //药品办结结束
        if (
          this.dataobj.status === "2" ||
          this.dataobj.taskName === "发起人阅知办结"
        ) {
          if (item.prop === "drugList_choose_member") {
            this.form[item.prop] = content["drugList"];
          }
          if (item.prop === "officegoodsList_choose_member") {
            this.form[item.prop] = content["officegoodsList"];
          }
          // 选药显示发放数量
          if (
            (item.prop === "drugList_choose_member" ||
              item.prop === "officegoodsList_choose_member") &&
            item.children.column &&
            item.children.column.length > 0
          ) {
            item.children.column.map((c) => {
              if (c.prop === "realAmount") {
                c.width = 180;
                c.disabled = true;
              }
            });
          }
        }
      });
      this.newOption = Object.assign({}, this.option);
      this.newOption.column = column;
      this.newOption.menuBtn = false;
      this.newOption.printBtn = true;
    }
  },
  computed: {
    ...mapGetters(["userInfo", "tagList"]),
  },
  methods: {
    init() {
      fetchTree().then((response) => {
        this.areaData = response.data.data;
      });
    },
    revoke(item) {
      let params = {
        billId: item.billId,
        flag: "撤回",
        taskId: item.taskId,
      };
      this.$prompt("请输入撤回原因", "确认撤回?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      }).then(({ value }) => {
        params.comment = value;
        billRevoke(params).then((response) => {
          this.$message.success("撤回成功");
          this.$router.go(-1);
        });
      });
    },
    printer() {
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)",
      });
      setTimeout(() => {
        loading.close();
        this.$print(this.$refs.renderForm);
      }, 2000);
    },
    alarmHandle() {
      this.form.assetList_choose_member = this.chosememberList1;
      this.closeDialog1();
    },
    listener() {
      let self = this;
      document.addEventListener("click", function (e) {
        self.chosedKey = [];
        // 表单选人
        let keyw = "";
        if (
          ((e.target.className === "el-input__inner" ||
            e.target.className === "el-input-group__append") &&
            e.target.offsetParent &&
            ((e.target.offsetParent.attributes.title &&
              e.target.offsetParent.attributes.title.value === "人员选择" &&
              e.target.readOnly !== true) ||
              (e.target.offsetParent.attributes.class &&
                e.target.offsetParent.attributes.class.value.indexOf(
                  "chosemember"
                ) != -1 &&
                e.target.readOnly !== true))) ||
          (e.target.innerHTML === "选择" &&
            e.target.offsetParent &&
            e.target.offsetParent.className === "el-input-group__append" &&
            e.target.offsetParent.offsetParent &&
            e.target.offsetParent.offsetParent.attributes.title &&
            e.target.offsetParent.offsetParent.attributes.title.value ===
              "人员选择") ||
          (e.target.innerHTML === "选择" &&
            e.target.offsetParent &&
            e.target.offsetParent.className === "el-input-group__append" &&
            e.target.offsetParent.offsetParent &&
            e.target.offsetParent.offsetParent.attributes.class &&
            e.target.offsetParent.offsetParent.attributes.class.value.indexOf(
              "chosemember"
            ) != -1)
        ) {
          if (e.target.className) {
            self.labelkey = e.path[4].children[0].htmlFor;
          } else {
            self.labelkey = e.path[5].children[0].htmlFor;
          }
          if (
            self.dataobj.code === "asset_bill_handover" ||
            self.dataobj.code === "asset_bill_change"
          ) {
            self.type = "radio";
          } else {
            self.type = "checkbox";
          }
          self.showChose = true;
          self.url1 = "/admin/dept/tree";
          keyw = "userId";
          self.url2 = "/admin/user/page/simple";
          self.title = "组织机构";
          self.flKey = "deptId";
          self.columns = [
            {
              title: "用户名",
              dataIndex: "username",
              key: "username",
            },
            {
              title: "姓名",
              key: "realname",
              dataIndex: "realname",
            },
            {
              title: "所属部门",
              dataIndex: "deptId",
              key: "deptId",
              scopedSlots: { customRender: "deptId" },
            },
            {
              title: "岗位",
              dataIndex: "post",
              key: "post",
              scopedSlots: { customRender: "post" },
            },
          ];
          self.columns1 = [
            {
              title: "姓名",
              dataIndex: "realname",
              key: "realname",
            },
            {
              title: "操作",
              key: "action",
              scopedSlots: { customRender: "action" },
            },
          ];
        }
        // 表单选药
        if (
          e.target.innerHTML === "药品名称【请选择(个人领药)+】" ||
          e.target.innerHTML === "药品名称【请选择(批量领药)+】" ||
          e.target.innerHTML === "药品名称【请选择(老干领药)+】"
        ) {
          self.labelkey = "drugList_choose_member";
          self.showChose = true;
          self.url1 = "/act/drugcategory/tree";
          // self.url2 = '/act/drug/page'
          self.url2 = "/act/drugstock/page";
          self.title = "药品类别";
          self.limitLabel = e.target.innerHTML;
          self.columns = [
            {
              title: "药品名",
              dataIndex: "name",
              key: "name",
              width: 150,
            },
            {
              title: "简称",
              key: "pinyin",
              width: 100,
              dataIndex: "pinyin",
            },
            {
              title: "药品单位",
              key: "unit",
              width: 100,
              align: "center",
              dataIndex: "unit",
            },
            {
              title: "适应症",
              dataIndex: "indications",
              key: "indications",
            },
            {
              title: "注意事项",
              dataIndex: "attention",
              key: "attention",
            },
          ];
          self.flKey = "categoryId";
          self.columns1 = [
            {
              title: "药品名",
              dataIndex: "name",
              key: "name",
            },
            {
              title: "操作",
              key: "action",
              scopedSlots: { customRender: "action" },
            },
          ];
          keyw = "drugId";
        }
        // 办公用品申请
        if (
          e.target.innerHTML === "用品名称【请选择+】" ||
          e.target.innerHTML === "采购用品名称【请选择+】"
        ) {
          self.labelkey = "officegoodsList_choose_member";
          self.showChose = true;
          self.url1 = "/act/officegoodscategory/tree";
          self.url2 = "/act/officegoodsstock/page";
          self.title = "用品类别";
          keyw = "officegoodsId";
          self.limitLabel = e.target.innerHTML;
          self.columns = [
            {
              title: "序号",
              width: 30,
              align: "center",
              customRender: (text, record, index) => `${index + 1}`,
            },
            {
              title: "用品名",
              dataIndex: "name",
              key: "name",
              width: 150,
            },
            {
              title: "图片",
              key: "cover",
              width: 100,
              scopedSlots: { customRender: "cover" },
              dataIndex: "cover",
            },
          ];
          self.flKey = "categoryId";
          self.columns1 = [
            {
              title: "用品名",
              dataIndex: "name",
              key: "name",
            },
            {
              title: "操作",
              key: "action",
              scopedSlots: { customRender: "action" },
            },
          ];
        }
        // 维修申请
        if (
          e.target.innerHTML === "维修资产【请选择+】" ||
          e.target.innerHTML === "资产名称【请选择+】" ||
          e.target.innerHTML === "退库资产【请选择+】" ||
          e.target.innerHTML === "借用资产【请选择+】"
        ) {
          self.labelkey = "assetList_choose_member";
          self.showChose = true;
          self.url1 = "/act/assetcategory/tree?status=1";
          self.url2 = "/act/asset/page";
          self.title = "资产类别";
          self.limitLabel = e.target.innerHTML;
          self.columns = [
            {
              title: "资产名",
              dataIndex: "name",
              key: "name",
              width: 150,
            },
            {
              title: "规格",
              key: "spec",
              width: 80,
              dataIndex: "no",
            },
            {
              title: "单位",
              key: "unit",
              width: 80,
              dataIndex: "unit",
            },
            {
              title: "编号",
              key: "no",
              width: 100,
              dataIndex: "no",
            },
            {
              title: "sn",
              key: "sn",
              width: 80,
              dataIndex: "sn",
            },
            {
              title: "品牌",
              key: "brand",
              width: 80,
              dataIndex: "brand",
            },
            {
              title: "地址",
              key: "address",
              width: 150,
              dataIndex: "address",
            },
            {
              title: "图片",
              key: "cover",
              width: 100,
              scopedSlots: { customRender: "cover" },
              dataIndex: "cover",
            },
          ];
          self.flKey = "categoryId";
          self.columns1 = [
            {
              title: "资产名",
              dataIndex: "name",
              key: "name",
            },
            {
              title: "操作",
              key: "action",
              scopedSlots: { customRender: "action" },
            },
          ];
        }
        if (e.target.innerHTML === "已选资产【请选择+】") {
          self.columns = [
            {
              title: "资产名",
              dataIndex: "name",
              key: "name",
              width: 150,
            },
            {
              title: "规格",
              key: "spec",
              width: 80,
              dataIndex: "no",
            },
            {
              title: "单位",
              key: "unit",
              width: 80,
              dataIndex: "unit",
            },
            {
              title: "编号",
              key: "no",
              width: 100,
              dataIndex: "no",
            },
            {
              title: "sn",
              key: "sn",
              width: 80,
              dataIndex: "sn",
            },
            {
              title: "品牌",
              key: "brand",
              width: 80,
              dataIndex: "brand",
            },
            {
              title: "地址",
              key: "address",
              width: 150,
              dataIndex: "address",
            },
            {
              title: "图片",
              key: "cover",
              width: 100,
              scopedSlots: { customRender: "cover" },
              dataIndex: "cover",
            },
          ];
          self.dialogVisible1 = true;
        }
        if (
          self.form[self.labelkey] &&
          typeof self.form[self.labelkey] === "object"
        ) {
          self.form[self.labelkey].map((item) => {
            self.chosedKey.push(item[keyw]);
          });
          self.choselist = self.form[self.labelkey];
        } else if (typeof self.form[self.labelkey] == "string") {
          self.choselist.map((item) => {
            self.chosedKey.push(item[keyw]);
          });
        }
      });
    },
    closeDialog1() {
      this.dialogVisible1 = false;
    },
    selectMembers1(selectedRowKeys, selectedRows) {
      this.selectedRowKeys1 = selectedRowKeys;
      this.chosememberList1 = selectedRows;
    },
    handleTableChange1(pagination, filters, sorter) {
      this.page2.current = pagination.current;
      this.getmemberList(this.page2);
    },
    banClick() {
      Array.from(
        document.getElementsByClassName("el-popover__reference")
      ).forEach((v, index) => {
        if (
          v.innerHTML === "药品名称【请选择(个人领药)+】" ||
          v.innerHTML === "药品名称【请选择(批量领药)+】" ||
          v.innerHTML === "药品名称【请选择(老干领药)+】" ||
          v.innerHTML === "用品名称【请选择+】" ||
          v.innerHTML === "采购用品名称【请选择+】" ||
          v.innerHTML === "资产名称【请选择+】" ||
          v.innerHTML === "维修资产【请选择+】" ||
          v.innerHTML === "已选资产【请选择+】" ||
          v.innerHTML === "退库资产【请选择+】" ||
          v.innerHTML === "借用资产【请选择+】"
        ) {
          // 资产领用发放节点
          if (
            (this.dataobj.code === "asset_bill_requisition" ||
              this.dataobj.code === "asset_bill_revert" ||
              this.dataobj.code === "asset_bill_borrow" ||
              this.dataobj.code === "asset_bill_handover" ||
              this.dataobj.code === "asset_bill_purchase" ||
              this.dataobj.code === "drug_bill_personal" ||
              this.dataobj.code === "drug_bill_batch" ||
              this.dataobj.code === "drug_bill_cadre" ||
              this.dataobj.code === "officegoods_bill_apply") &&
            this.dataobj.canTodo &&
            this.dataobj.taskConfig &&
            this.dataobj.taskConfig.properties
          ) {
            v.style.cursor = "pointer";
            v.style.color = "red";
          } else {
            v.style.pointerEvents = "none";
            v.style.color = "#000";
          }
        }
      });
    },
    getPfy() {
      remote("approval_common").then((response) => {
        this.restaurants = response.data.data;
        this.banClick();
      });
    },
    saveNodeTask(value) {
      let self = this;

      console.log(value);
      // if (!this.state1) {
      //   this.$message.error('请填写批复意见')
      //   return
      // }
      let params = {
        billId: this.dataobj.billId,
        comment: this.state1 ? value + "。" + this.state1 : value,
        flag: value,
        taskId: this.dataobj.taskId,
      };
      let methodFlag = false;
      // 非办结
      if (Object.keys(this.bizData).length > 0) {
        Object.keys(this.bizData).map((item) => {
          this.bizData[item] = this.form[item];
          if (item === "method") {
            methodFlag = true;
          }
        });
        if (methodFlag && !this.bizData.method) {
          this.$message.error("请选择用车方式");
          return;
        } else if (this.bizData.method === "1") {
          if (!this.form.driverId) {
            this.$message.error("请选择驾驶员");
            return;
          } else {
            this.bizData.driverId = this.form.driverId;
          }
          if (!this.form.carNo) {
            this.$message.error("请选择车辆");
            return;
          } else {
            this.bizData.carNo = this.form.carNo;
          }
        }
        params.bizData = this.bizData;
      }
      let submitFlag = true;
      // 办结
      if (
        this.dataobj.canTodo &&
        this.dataobj.taskConfig &&
        this.dataobj.taskConfig.properties &&
        value !== "不同意"
      ) {
        // 选药办结
        if (
          this.dataobj.code === "drug_bill_personal" ||
          this.dataobj.code === "drug_bill_batch" ||
          this.dataobj.code === "drug_bill_cadre"
        ) {
          this.form.drugList_choose_member.map((item) => {
            if (!item.preAmount && item.preAmount !== 0 && submitFlag) {
              submitFlag = false;
              this.$message.error("请填写数量");
              return;
            }
            if (!item.realAmount && item.realAmount !== 0 && submitFlag) {
              submitFlag = false;
              this.$message.error("请填写发放数量");
              return;
            }
            if (
              item.realAmount &&
              item.realAmount > item.limitAmount &&
              submitFlag &&
              this.dataobj.code != "drug_bill_batch"
            ) {
              submitFlag = false;
              this.$message.error("发放数量不得超过限额数量");
              return;
            }
          });
          if (submitFlag) {
            let obj = {};
            obj["drugList"] = this.form.drugList_choose_member;
            obj["drugList_choose_member"] = this.form.drugList_choose_member;
            obj["choselist"] = this.form.drugList_choose_member;
            obj["chosedKey"] = this.form.drugList_choose_member.map((item) => {
              return item.drugId;
            });
            params["bizData"] = obj;
          }
        }
        // 用品办结
        if (this.dataobj.code === "officegoods_bill_apply") {
          this.form.officegoodsList_choose_member.map((item) => {
            if (!item.realAmount && item.realAmount !== 0 && submitFlag) {
              submitFlag = false;
              this.$message.error("请填写发放数量");
              return;
            }
            if (
              item.realAmount &&
              item.realAmount > item.limitAmount &&
              submitFlag
            ) {
              submitFlag = false;
              this.$message.error("发放数量不得超过限额数量");
              return;
            }
          });
          if (submitFlag) {
            let obj = {};
            obj["officegoodsList"] = this.form.officegoodsList_choose_member;
            params["bizData"] = obj;
          }
        }
        // 用车办结
        if (this.dataobj.code === "car_bill_apply") {
          let obj = {};
          if (
            !this.form.createPhone &&
            this.form.createPhone !== 0 &&
            submitFlag
          ) {
            submitFlag = false;
            this.$message.error("请填写联系电话");
            return;
          }
          if (!this.form.reason && this.form.reason !== 0 && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写出车事由");
            return;
          }
          if (
            (!this.form.useTimes || this.form.useTimes.length === 0) &&
            submitFlag
          ) {
            this.form.useTimes = [this.form.startTime,this.form.endTime]
          }
          if (!this.form.carModel && this.form.carModel !== 0 && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写车辆型号");
            return;
          }
          if (
            !this.form.car_address &&
            this.form.car_address !== 0 &&
            submitFlag
          ) {
            submitFlag = false;
            this.$message.error("请填写出车地点");
            return;
          }
          if (
            !this.form.outAddress &&
            this.form.outAddress !== 0 &&
            submitFlag
          ) {
            submitFlag = false;
            this.$message.error("请填写外出地点");
            return;
          }
          if (this.form.car_address === "其他" && !this.form.address_other) {
            this.$message.error("请填写其他出车地点");
            return;
          } else if (this.form.car_address !== "其他") {
            this.form.address = this.form.car_address;
          } else {
            this.form.address = this.form.address_other;
          }
          if (submitFlag) {
            obj = Object.assign({}, this.form);
            params["bizData"] = obj;
          }
        }
        // 采购办结
        if (this.dataobj.code === "officegoods_bill_purchase") {
          this.form.officegoodsList_choose_member.map((item) => {
            if (!item.realAmount && item.realAmount !== 0) {
              item.realAmount = item.preAmount;
            }
            // if (!item.realAmount && item.realAmount !== 0 && submitFlag) {
            //   submitFlag = false
            //   this.$message.error('请填写入库数量')
            //   return
            // }
            // if(item.realAmount && item.realAmount > item.limitAmount && submitFlag) {
            //   submitFlag = false
            //   this.$message.error('入库数量不得超过限额数量')
            //   return
            // }
          });
          if (submitFlag) {
            let obj = {};
            obj["officegoodsList"] = this.form.officegoodsList_choose_member;
            params["bizData"] = obj;
          }
        }
        // 住房办结
        if (this.dataobj.code === "housing_bill_apply") {
          if (this.dataobj.taskName === "机关服务中心资产组意见") {
            if (!this.form1.housingId && submitFlag) {
              submitFlag = false;
              this.$message.error("请选择公有住房");
              return;
            }
            if (
              this.form1.housingId &&
              this.form1.housingType === "2" &&
              !this.form1.bedId &&
              submitFlag
            ) {
              submitFlag = false;
              this.$message.error("请选择床位");
              return;
            }
          }
          // if (!this.form1.leadDate && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请选择交付使用时间')
          //   return
          // }
          if (
            !this.form1.remark &&
            submitFlag &&
            this.dataobj.taskName === "机关服务中心经办人办理"
          ) {
            submitFlag = false;
            this.$message.error("请输入办理情况");
            return;
          }
          if (submitFlag) {
            params["bizData"] = this.form1;
          }
        }
        // 维修办结
        if (this.dataobj.code === "repair_bill_apply") {
          // if (!this.form.workTime && this.form.workTime !== 0 && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请填写工期')
          //   return
          // }
          // if (!this.form.workTimePrice && this.form.workTimePrice !== 0 && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请填写工时费用')
          //   return
          // }
          // if (!this.form.consumablePrice && this.form.consumablePrice !== 0 && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请填写耗材总费用')
          //   return
          // }
          // if (!this.form.workPrice && this.form.workPrice !== 0 && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请填写总费用')
          //   return
          // }
          if (submitFlag) {
            let att = {
              workTime: this.form.workTime,
              workPrice: this.form.workPrice,
              consumablePrice: this.form.consumablePrice,
              workTimePrice: this.form.workTimePrice,
              attachment: this.form.attachment,
              remark: this.form.remark,
            };
            params["bizData"] = att;
          }
        }
        // 资产领用办结
        if (
          this.dataobj.code === "asset_bill_requisition" ||
          this.dataobj.code === "asset_bill_revert" ||
          this.dataobj.code === "asset_bill_borrow" ||
          this.dataobj.code === "asset_bill_purchase"
        ) {
          let obj = {};
          if (!this.form.remark && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写内容");
            return;
          } else {
            obj.remark = this.form.remark;
          }
          if (submitFlag) {
            obj["assetList"] = this.form.assetList_choose_member;
            params["bizData"] = obj;
          }
        }
        // 资产变动办结
        if (this.dataobj.code === "asset_bill_handover") {
          let obj = {};
          if (this.form.areaId) {
            let list = getParentsNameById(this.form.areaId, this.areaData);
            obj.areaName = list.join("");
            obj.areaId = this.form.areaId;
          } else {
            submitFlag = false;
            this.$message.error("请选择区域");
            return;
          }
          if (!this.form.remark && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写变动内容");
            return;
          } else {
            obj.remark = this.form.remark;
          }
          if (submitFlag) {
            obj["address"] = this.form.address;
            obj["assetList"] = this.form.assetList_choose_member;
            params["bizData"] = obj;
          }
        }
        // 停车申请办结
        if (this.dataobj.code === "parking_bill_apply") {
          let obj = {};
          if (!this.form.parkingTimes || this.form.parkingTimes.length === 0) {
            submitFlag = false;
            this.$message.error("请选择申请停放时间");
            return;
          } else {
            obj.parkingTimes = this.form.parkingTimes;
          }
          if (!this.form.remark && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写备注");
            return;
          } else {
            obj.remark = this.form.remark;
          }
          if (submitFlag) {
            params["bizData"] = obj;
          }
        }
        // 来访申请办结
        if (this.dataobj.code === "visiting_bill_apply") {
          // let obj = {};
          // if (!this.form.validityDate) {
          //   submitFlag = false;
          //   this.$message.error("请选择拜访有效期");
          //   return;
          // } else {
          //   obj.validityDate = this.form.validityDate;
          // }
          // if (!this.form.remark && submitFlag) {
          //   submitFlag = false;
          //   this.$message.error("请填写备注");
          //   return;
          // } else {
          //   obj.remark = this.form.remark;
          // }
          // if (submitFlag) {
          //   params["bizData"] = obj;
          // }
        }
        // 办公房办结
        if (this.dataobj.code === "office_bill_apply") {
          if (!this.dataobj.useDates && submitFlag) {
            submitFlag = false;
            this.$message.error("请选择办公用房");
            return;
          } else {
            this.form2.useDates = this.dataobj.useDates;
          }
          if (!this.form2.officeId && submitFlag) {
            submitFlag = false;
            this.$message.error("请选择办公用房");
            return;
          }
          if (!this.form2.leadDate && submitFlag) {
            submitFlag = false;
            this.$message.error("请选择交付使用时间");
            return;
          }
          if (!this.form2.remark && submitFlag) {
            submitFlag = false;
            this.$message.error("请输入办理情况");
            return;
          }
          if (submitFlag) {
            params["bizData"] = this.form2;
          }
        }
        // IC卡办结
        if (this.dataobj.code === "card_bill_apply") {
          let obj = {};
          if (!this.form.cards && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写卡号");
            return;
          } else {
            obj.cards = this.form.cards;
          }
          if (!this.form.remark && submitFlag) {
            submitFlag = false;
            this.$message.error("请输入备注");
            return;
          } else {
            obj.remark = this.form.remark;
          }
          if (submitFlag) {
            params["bizData"] = obj;
          }
        }
        // 座机申请办结
        if (this.dataobj.code === "telephone_bill_apply") {
          let obj = {};
          // if (!this.form.appointmentDate && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请填写预约日期')
          //   return
          // } else {
          //   obj.appointmentDate = this.form.appointmentDate
          // }
          if (!this.form.numbers && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写号码");
            return;
          } else {
            obj.numbers = this.form.numbers;
          }
          if (
            (!this.form.useDates || this.form.useDates.length === 0) &&
            submitFlag
          ) {
            submitFlag = false;
            this.$message.error("请填写使用时间");
            return;
          } else {
            obj.useDates = this.form.useDates;
          }
          // if (!this.form.items && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请填写物品品目')
          //   return
          // } else {
          //   obj.items = this.form.items
          // }
          if (!this.form.remark && submitFlag) {
            submitFlag = false;
            this.$message.error("请输入备注");
            return;
          } else {
            obj.remark = this.form.remark;
          }
          if (submitFlag) {
            params["bizData"] = obj;
          }
        }
        // 座机号码迁移申请
        if (
          this.dataobj.code === "telephone_bill_migrate" ||
          this.dataobj.code === "telephone_bill_long"
        ) {
          let obj = {};
          // if (!this.form.appointmentDate && submitFlag) {
          //   submitFlag = false
          //   this.$message.error('请填写预约日期')
          //   return
          // } else {
          //   obj.appointmentDate = this.form.appointmentDate
          // }
          if (!this.form.number && submitFlag) {
            submitFlag = false;
            this.$message.error("请填写原号码");
            return;
          } else {
            obj.number = this.form.number;
          }
          if (!this.form.remark && submitFlag) {
            submitFlag = false;
            this.$message.error("请输入备注");
            return;
          } else {
            obj.remark = this.form.remark;
          }
          if (submitFlag) {
            params["bizData"] = obj;
          }
        }
      }
      // 综合
      if (this.dataobj.code === "meeting_bill_apply" && value != "不同意") {
        if (this.dataobj.taskName === "机关服务中心资产组意见") {
          if (!this.form1.housingId && submitFlag) {
            submitFlag = false;
            this.$message.error("请选择公有住房");
            return;
          } else {
            if (this.form1.housing) {
              this.form1.housing.housingId = this.form1.housingId;
            }
          }
          if (this.form1.housingType) {
            this.form1.housing.housingType = this.form1.housingType;
            this.form1.housing.address = this.form1.address;
            this.form1.housing.constructionArea = this.form1.constructionArea;
            this.form1.housing.rentArea = this.form1.rentArea;
            this.form1.housing.defaultRent = this.form1.defaultRent;
          }
          if (
            this.form1.housingId &&
            this.form1.housingType === "2" &&
            !this.form1.bedId &&
            submitFlag
          ) {
            submitFlag = false;
            this.$message.error("请选择床位");
            return;
          } else if (
            this.form1.housingId &&
            this.form1.housingType === "2" &&
            this.form1.bedId &&
            submitFlag
          ) {
            this.form1.housing.bedId = this.form1.bedId;
            this.form1.housing.bedNumber = this.form1.bedNumber;
          }
        }
        // if (!this.form1.leadDate && submitFlag) {
        //   submitFlag = false
        //   this.$message.error('请选择交付使用时间')
        //   return
        // }
        if (submitFlag) {
          params["bizData"] = this.form1;
        }
      }
      // if (this.dataobj.showSelectType &&  this.dataobj.showSelectType == 'ROLE_SERVICE_HANDEL' &&  value === '同意') {
      if (
        this.dataobj.showSelectType &&
        (value === "同意" ||
          (value === "送审批" &&
            this.dataobj.code !== "repair_bill_apply" &&
            this.dataobj.code !== "parking_bill_apply" &&
            this.dataobj.code !== "telephone_bill_apply" &&
            this.dataobj.code !== "telephone_bill_migrate" &&
            this.dataobj.code !== "card_bill_apply" &&
            this.dataobj.code !== "telephone_bill_long" &&
            this.dataobj.code !== "construction_bill" &&
            this.dataobj.code !== "meeting_bill_apply"))
      ) {
        let atts = this.dataobj.showSelectType.split("_#_");
        if (atts.length > 1) {
          if (!this.form.assignee || this.form.assignee.length === 0) {
            this.$message.error("请选择" + atts[1]);
            done();
            return;
          } else {
            params.assignee = this.form.assignee.join();
          }
          // } else {
          //   if (!this.form.assignee || this.form.assignee.length === 0) {
          //     if (this.dataobj.showSelectType == 'ROLE_SERVICE_HANDEL' || this.dataobj.showSelectType == 'ROLE_SERVICE_ASSET_HANDEL') {
          //       this.$message.error('请选择经办人')
          //     } else if (this.dataobj.showSelectType == 'ROLE_SERVICE_GROUP_LEADER_KS'){
          //       this.$message.error('请选择科组长')
          //     } else if (this.dataobj.showSelectType == 'ROLE_SERVICE_CHARGE_LEADER') {
          //       this.$message.error('请选择分管领导')
          //     }
          //     return
          //   } else {
          //     params.assignee = this.form.assignee.join()
          //   }
        }
      }
      if (
        this.dataobj.code == "meeting_bill_apply" &&
        this.dataobj.showSelectType &&
        value == "分办"
      ) {
        let atts = this.dataobj.showSelectType.split("_#_");
        if (atts.length > 1) {
          if (!this.form.assignee || this.form.assignee.length === 0) {
            this.$message.error("请选择" + atts[1]);
            done();
            return;
          } else {
            params.assignee = this.form.assignee.join();
          }
        }
      }
      if (submitFlag) {
        this.$confirm("确定处理?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            try {
              if (params.bizData.idCard) {
                console.log(params, "@start");
                // 按钮的状态
                if (this.$refs.newData.radio1 === 0) {
                  params.bizData.billChecked =
                    params.bizData.billChecked.filter((item) => item != 1);
                } else {
                  params.bizData.billChecked.push(1);
                }
                if (this.$refs.newData.radio2 === 0) {
                  params.bizData.billChecked =
                    params.bizData.billChecked.filter((item) => item != 2);
                } else {
                  params.bizData.billChecked.push(2);
                }
                if (this.$refs.newData.radio3 === 0) {
                  params.bizData.billChecked =
                    params.bizData.billChecked.filter((item) => item != 3);
                } else {
                  params.bizData.billChecked.push(3);
                }
                if (this.$refs.newData.radio4 === 0) {
                  params.bizData.billChecked =
                    params.bizData.billChecked.filter((item) => item != 4);
                } else {
                  params.bizData.billChecked.push(4);
                }

                // 基础信息
                params.bizData.newStaffName =
                  this.$refs.newData.ruleForm.newStaffName;
                params.bizData.newStaffPhone =
                  this.$refs.newData.ruleForm.newStaffPhone;
                params.bizData.newStaffType =
                  this.$refs.newData.ruleForm.newStaffType;
                params.bizData.newStaffAddr =
                  this.$refs.newData.ruleForm.newStaffAddr;
                params.bizData.newStaffType =
                  this.$refs.newData.ruleForm.newStaffType;

                // 上传的文件
                params.bizData.attachment =
                  this.$refs.newData.ruleForm.attachment;
                params.bizData.fileList1 =
                  this.$refs.newData.ruleForm.fileList1;
                params.bizData.fileList2 =
                  this.$refs.newData.ruleForm.fileList2;

                //时间变化 createTime
                params.bizData.startDate =
                  this.$refs.newData.ruleForm.startDate;
                params.bizData.endDate = this.$refs.newData.ruleForm.endDate;
                params.bizData.applyTimes = [
                  params.bizData.startDate,
                  params.bizData.endDate,
                ];
                params.bizData.createTime =
                  this.$refs.newData.ruleForm.createTime + " 00:00:00";

                console.log(params.bizData);
                console.log(this.$refs.newData);
                // 房间和车牌  avatarUrl
                if (!this.$refs.newData.avatarUrl) {
                  this.$refs.newData.ruleForm.idCard.pic = "";
                } else {
                  this.$refs.newData.ruleForm.idCard.pic =
                    this.$refs.newData.cover;
                }

                // 上传图片
                params.bizData.idCard = {
                  ...this.$refs.newData.ruleForm.idCard,
                };
                params.bizData.housing = {
                  ...this.$refs.newData.ruleForm.housing,
                };
              }
            } catch (err) {
              console.log(err);
            }

            console.log(params, "@end");

            billSubmit(params).then((response) => {
              this.$message.success("处理成功");
              let path = self.$route.path;
              let list = self.tagList.filter((item) => {
                return item.value !== "/approvaltask/index";
              });
              setStore({ name: "tagList", content: list, type: "session" });
              let tag = self.tagList.filter((item) => {
                return item.value.indexOf("/db/detail") !== -1;
              });
              if (tag.length > 0) {
                this.$router.$avueRouter.closeTag(tag[0]);
              }
              this.$router.push({
                path: "/approvaltask/index",
              });
            });
          })
          .catch((err) => {
            done();
          });
      }
    },
    querySearch(queryString, cb) {
      var restaurants = this.restaurants;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return (restaurant) => {
        return (
          restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
          0
        );
      };
    },
    eventBusHandle() {
      let _this = this;
      eventBus.$on("getMember", function (data) {
        _this.chosedKey = data.chosedKey;
        _this.choselist = data.choselist;
        _this.form = Object.assign(_this.form, data);
      });
    },
    handlePreviewSubmit() {
      let formDta = Object.assign(this.dataobj);
      formDta.bizData = this.form;
      startProcess(formDta).then((response) => {
        this.$message.success("提交成功");
        this.close();
      });
    },
    getItemModal() {
      this.close();
    },
    close() {
      this.$emit("getModal1", false);
    },
  },
};
</script>
<style>
.viewer-backdrop {
  background-color: rgba(245, 247, 250);
}
</style>
<style lang="scss" scoped>
.view-wrapper {
  /deep/.el-tabs {
    height: 800px;
    .el-tabs__content {
      .el-autocomplete {
        width: 100%;
        margin-top: 10px;
        textarea {
          height: 80px;
        }
      }
    }
  }
  /deep/ .avue-crud__menu {
    justify-content: flex-end;
    .avue-crud__right {
      display: none;
    }
  }
  /deep/ .el-timeline {
    margin-top: 20px;
  }
  /deep/.el-form-item {
    .avue-input {
      .el-input-group__append {
        // display: none;
      }
    }
  }
}

@media print {
  #printForm {
    height: auto !important;
    padding-bottom: 2px;
    padding-right: 2px;
  }
  body {
    margin-top: 10mm;
    margin-bottom: 10mm;
    margin-left: 5mm;
    margin-right: 5mm;
  }
  .el-radio__input.is-disabled.is-checked + span.el-radio__label {
    color: #000;
  }
}
@page {
  margin: 8mm 2mm;
  .el-radio__input.is-disabled.is-checked + span.el-radio__label {
    color: #000;
  }
}
</style>
